/*
 * init/main.c
 *
 * last modified by ChenJie at 2007.07.15
 *
 */
#include <cos/kernel.h>
#include <cos/mm.h>
#include <cos/sched.h>
#include <cos/time.h>
#include <cos/protect.h>
#include <cos/interrupt.h>
#include <cosstd.h>

extern void cpu_info(void);

void idle_task();
void clock_task();
void system_task();

void pm_task();
void fs_task();
void rs_task();
void mem_task();
void log_task();
void tty_task();
void at_wini_task();
void init_task();

struct bootprocs_struct bootprocs[NR_BOOT_PROCS]={
	/*pid,       entry,   ulevel, priority, counter, ipc_mask, name[20] */
	{IDLE, 		idle_task, 	1,  0xf, 40, 0x00000000, "KERNEL"},
	{CLOCK,		clock_task,	1,  0x0, 40, 0x00000000, "CLOCK"},
	{SYSTEM, 	system_task,	1,  0x0, 40, 0x00000000, "SYSTEM"},
	{HARDWARE, 	NULL, 		0,  0x0,  0, 0x00000000, "HARDWARE"},
	{PM_PROC,	pm_task,	2,  0x2, 20, 0x00000000, "PM"},
	{FS_PROC,	fs_task,	2,  0x2, 20, 0x00000000, "FS"},
	{RS_PROC,	rs_task,	2,  0x2, 20, 0x00000000, "RS"},
	{MEM_PROC,	mem_task,	2,  0x1, 20, 0x00000000, "MEM"},
	{LOG_PROC,	log_task,	2,  0x1, 20, 0x00000000, "LOG"},
	{TTY_PROC,	tty_task,	2,  0x1, 20, 0x00000000, "TTY"},
	{DRVR_PROC,	at_wini_task,	2,  0x1, 20, 0x00000000, "DRVR"},
	{INIT_PROC,	init_task,	3,  0x3, 20, 0x00000000, "INIT"}
};

void main(void)
{
	interrupt_init();
	mm_init(EXT_MM_SIZE);
	time_init();
	sched_init();
//	cpu_info();
//	printk("Kernel Size = %dKB\n\r", KERNEL_SIZE>>10);	
//	printk("MEM_SIZE = %dMb.\n\r", mm_size>>20);
	begin_schedule();
}

void idle_task(void)
{
	int i;
	for(i=-3; i<=INIT_PROC; i++) notify(i);
	while(1){ halt();}
}




